<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>玩转json</title>
</head>

<body>
    <h2>js的json</h2>

    <h4>JSON.parse: 解析成js对象 </h4>
    <h4>JSON.stringify: 转化为json</h4>



    <script>

        var text = '{ "name":"奥拉夫",  "age":62, "city":"恕瑞玛" }';

        //json转换为js对象
        var obj = JSON.parse(text);
        console.log("json转换为js对象", obj)

        //js对象转化为json 
        var jsonStr = JSON.stringify(obj);
        console.log('js对象转化为json', jsonStr)


    </script>
</body>

</html>